home *** CD-ROM | disk | FTP | other *** search
- Path: sdrc.com!thor!scjones
- From: larry.jones@sdrc.com (Larry Jones)
- Newsgroups: comp.lang.c
- Subject: Re: operator % - compiler error
- Date: 21 Mar 1996 22:07:53 GMT
- Organization: SDRC Engineering Services
- Distribution: world
- Message-ID: <4isjvp$c23@info1.sdrc.com>
- References: <4ini8g$i1u@spanky.pls.ov.com> <4iro6q$2e9@nntp.interaccess.com>
- NNTP-Posting-Host: thor.sdrc.com
- Originator: scjones@thor
-
- In article <4iro6q$2e9@nntp.interaccess.com>, brianmcg@interaccess.com (Brian V. McGroarty) writes:
- > This is something I've wondered about. Why isn't the mod operator defined
- > for floating point math? It can be implemented easily enough via something
- > like:
- >
- > #define MOD( base, op ) ( (base) - ( (base) / (op) ) * (op) )
-
- Not quite -- you need to convert the result of the division to an
- integer somehow before multiplying. Simply put, floating point
- remainder is a complicated enough operation that it got a library
- routine (fmod or modf, I can never remember which is which) instead.
- ----
- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070
- larry.jones@sdrc.com
- Why can't I ever build character in a Miami condo or a casino somewhere?
- -- Calvin
-